﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MyBiz.Core.Products;

namespace MyBiz.Core
{
    /// <summary>
    /// Касса. Проверяет и выдает/принимает деньги
    /// </summary>
    public  class FinanceBox : IEntity
    {
        protected Money _money;
        public string Id { get; private set; }
        public string Name { get; private set; }

        public Money Money
        {
            get { return _money; }
        }

        /// <summary>
        /// Проверить доступность средст на покупку
        /// </summary>
        /// <param name="product"></param>
        /// <returns></returns>
        public virtual bool CheckIn(IProduct product)
        {
            _money -= product.Cost * product.Count;

            return true;
        }


        /// <summary>
        /// Провести продажу
        /// </summary>
        /// <param name="product"></param>
        /// <returns></returns>
        public bool CheckOut(IProduct product)
        {
            _money += product.Count*product.Price;

            return true;
        }
    }
}
